<!doctype html>
<html lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>线性渐变模拟长阴影</title>
</head>
<style>
  body {
    background: linear-gradient(90deg, hsl(199, 98%, 50%), hsl(199, 98%, 38%));
    overflow: hidden;
  }

  div {
    position: relative;
    width: 30vmin;
    height: 30vmin;
    background: #fff;
    margin: 30vmin auto;
  }

  div::before,
  div::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
  }

  div::before {
    transform-origin: 0 50%;
    transform: translate(100%, 0) skewY(45deg) scaleX(.6);
    background: linear-gradient(90deg, rgba(0, 0, 0, .3), transparent);
    animation: shadowMoveY 5s infinite linear alternate;
  }

  div::after {
    transform-origin: 0 0;
    transform: translate(0%, 100%) skewX(45deg) scaleY(.6);
    background: linear-gradient(180deg, rgba(0, 0, 0, .3), transparent);
    animation: shadowMoveX 5s infinite linear alternate;
  }

  @keyframes shadowMoveX {
    to {
      transform: translate(0%, 100%) skewX(50deg) scaleY(.6);
    }
  }

  @keyframes shadowMoveY {
    to {
      transform: translate(100%, 0) skewY(40deg) scaleX(.6);
    }
  }
</style>
<body>
<ul>
  <li>借用了元素的两个伪元素</li>
  <li>通过渐变色填充两个伪元素，再通过位移、变换放置在合适的位置</li>
</ul>
<div></div>
</body>
</html>